require "import"
import "tools"
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS).setStatusBarColor(0xff4DB6AC)
activity.setContentView("vpCrop_")
crop.background=btBackground
oDir.text=LUA_SD.."/avHandle/output/"
iDir.onClick=function()
  ChoiceFile(LUA_SD,function(dir)
    iDir.text=dir
  end)
end
oDir.onClick=function()
  ChoicePath(LUA_SD,function(dir)
    oDir.text=dir.."/"
  end)
end
crop. onClick=function()
  if File(iDir.text).exists()
    if filename.text~=""
      local w,h,x,y="","","",""
      if width.text~=""
        w=width.text
       else
        w="iw"
      end
      if height.text~=""
        h=height.text
       else
        h="ih"
      end
      if pos_x.text~=""
        x=pos_x.text
       else
        x="0"
      end
      if pos_y.text~=""
        y=pos_y.text
       else
        y="0"
      end
      local s=tostring(File(iDir.text).getName())
      s=s:sub(s:find("%."),#s)
      local cmd="-i "..iDir.text.." -vf crop="..w..":"..h..":"..x..":"..y.." -y "..oDir.text..filename.text..s
      activity.newActivity("handle",{cmd})
     else
      print("请输入文件名")
    end
   else
    print("所选文件不存在")
  end
end